﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sunimage.Spjg.BLL.Helper;
using Sunimage.Spjg.Common.Exceptions;
using Sunimage.Spjg.Common.SysMgr;
using Sunimage.Spjg.DAL.SysMgr;
using Sunimage.Spjg.DAL;

namespace Sunimage.Spjg.BLL.SysMgr
{
    public class RoleBl
    {
        public List<Role> GetAllRoles()
        {
            return RoleDa.GetAll();
        }


        /// <summary>
        /// 根据Id查询角色
        /// </summary>
        /// <param name="id">Id</param>
        /// <returns></returns>
        public Role GetRole(int id)
        {
            List<Role> roles = RoleDa.GetAll();
            Role role = roles.Find(r => r.Id.Equals(id));
            return role;
        }

        /// <summary>
        /// 更新角色及其权限
        /// </summary>
        /// <param name="role"></param>
        public void Update(Role role)
        {
            RoleDa.Update(role);
        }
    }
}
